package com.eastelsoft.smartiot.bssserver.service.impl;

import com.eastelsoft.smartiot.bssserver.domain.TCmCustomerCompany;
import com.eastelsoft.smartiot.bssserver.service.TCmCustomerCompanyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@SuppressWarnings("ALL")
@Service
public class TCmCustomerCompanyServiceImpl implements TCmCustomerCompanyService {

    @Autowired
    private com.eastelsoft.smartiot.bssserver.dao.TCmCustomerCompanyMapper TCmCustomerCompanyMapper;

    protected org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public List<TCmCustomerCompany> queryListByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        PageInfo pageInfo = new PageInfo(TCmCustomerCompanyMapper.selectAll());
        logger.info("******PageSize="+String.valueOf(pageInfo.getPageSize()));
        List<TCmCustomerCompany> menu = pageInfo.getList();
        for (TCmCustomerCompany m : menu){
            System.out.println("---"+m.getCusId());
        }
        return TCmCustomerCompanyMapper.selectAll();
    }

    @Override
    public int insert(TCmCustomerCompany TCmCustomerCompany) {
        return TCmCustomerCompanyMapper.insert(TCmCustomerCompany);
    }

    @Override
    public int updateByPrimaryKey(TCmCustomerCompany record) {
        return TCmCustomerCompanyMapper.updateByPrimaryKey(record);
    }

    @Override
    public int deleteByPrimaryKey(String cusId) {
        return TCmCustomerCompanyMapper.deleteByPrimaryKey(cusId);
    }

    @Override
    public TCmCustomerCompany findByCusId(String cusId) {
        // TODO Auto-generated method stub
        return TCmCustomerCompanyMapper.selectByPrimaryKey(cusId);
    }

    @Override
    public PageInfo queryPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        PageInfo pageInfo = new PageInfo(TCmCustomerCompanyMapper.selectAll());
        if ( pageInfo != null ){
            logger.info("******PageSize="+String.valueOf(pageInfo.getPageSize()));
            List<TCmCustomerCompany> menu = pageInfo.getList();
            for (TCmCustomerCompany m : menu){
                System.out.println("---"+m.getCusId());
            }
        }
        return pageInfo;
    }
}
